package com.legendframework.core.initialization.entity;

import com.legendframework.core.dao.annotation.Column;
import com.legendframework.core.log.enums.LoggerLevelEnum;
import com.legendframework.core.dao.annotation.Entity;
import com.legendframework.core.dao.entity.AbstractEntity;
import com.legendframework.core.dao.enums.DataType;
import com.legendframework.core.dao.yaml.enums.YamlStorageType;

import java.util.Collections;
import java.util.List;

/**
 * @author 196
 * @Description: 日志配置文件
 * @date 2019/12/12 10:02
 */
@Entity(type = DataType.YAML,yamlFileName = "logConfig",yamlStorageType = YamlStorageType.ONE_TO_ONE)
public class LogConfig extends AbstractEntity<LogConfig> {

    @Column(
            comments = {
                    "日志级别",
                    "权重: DEBUG > WARN > ERROR > INFO , 如设置为WARN , 则显示WARN及一下级别的日志信息, 不会显示DEBUG级别的信息"
            },
            sort = 2)
    private LoggerLevelEnum logLevel;

    @Column(
            comments = {
                    "模板日志输出",
                    "可选值:",
                    "   #SERVICE# : 服务名",
                    "   #LOG_LEVEL# : 日志级别",
                    "   #CLASS_NAME# : 类信息",
                    "   #DATE_TIME# : 日志产生日期",
                    "   #INFO# : 错误信息"
            },
            sort = 3)
    private String templateInfo;

    @Override
    public List<LogConfig> getDefaultEntitys() {
        LogConfig log = new LogConfig();
        log.setId("1");
        log.setLogLevel(LoggerLevelEnum.DEBUG);
        log.setTemplateInfo("[#SERVICE#][#LOG_LEVEL#][#CLASS_NAME#][#DATE_TIME#]: #INFO#");
        return Collections.singletonList(log);
    }

    public LoggerLevelEnum getLogLevel() {
        return logLevel;
    }

    public String getTemplateInfo() {
        return templateInfo;
    }

    public void setTemplateInfo(String templateInfo) {
        this.templateInfo = templateInfo;
    }

    public void setLogLevel(LoggerLevelEnum logLevel) {
        this.logLevel = logLevel;
    }
}
